import request from '@/utils/request'

// 获取主页面数据
export function getPaper(params) {
  return request({
    url: '/exam/paper',
    method: 'GET',
    params
  })
}

// 获取所属科目的下拉框
export function getsubTree() {
  return request({
    url: '/subject/tree',
    method: 'GET'
  })
}

// 选择试题
export function chooseQuest(params) {
  return request({
    url: '/exam/question',
    method: 'GET',
    params
  })
}

// 新建试卷
export function addNewPaper(data) {
  return request({
    url: '/exam/paper',
    method: 'POST',
    data
  })
}

// 获取详细信息，用于回显
export function getDetailPaper(id) {
  return request({
    url: `/exam/paper/${id}`,
    method: 'GET'
  })
}

// 编辑更新
export function updatePaper(data) {
  return request({
    url: `/exam/paper/${data.id}`,
    method: 'PUT',
    data
  })
}

// 主页删除功能
export function delPaper(id) {
  return request({
    url: `/exam/paper/${id}`,
    method: 'DELETE'
  })
}

//
export function changeBtn(id, type) {
  return request({
    url: `/exam/paper/${id}/${type}`,
    method: 'GET'
  })
}
